﻿@model PermissionItemModel

@{
    Layout = "_AdminPopupLayout";

    //page title
    ViewBag.PageTitle = T("Admin.Configuration.ACL.Permission.Edit").Text;

    @if (ViewBag.RefreshPage == true)
    {
        <script>
            try {
                var el = $(window.opener.document.getElementById('permission-applied-for-@Model.Id'));
                el.text('@Model.PermissionAppliedFor');
            }
            catch (e) {
            }
            window.close();
        </script>
    }
}

<form asp-controller="Security" asp-action="PermissionEditPopup">
    <section class="content">
        <div class="container-fluid">
            <div class="content-header clearfix">
                <h1 class="float-left">
                    @T("Admin.Configuration.ACL.Permission.Edit")
                </h1>
                <div class="float-right">
                    <button type="submit" name="save" class="btn btn-primary">
                        <i class="far fa-floppy-disk"></i>
                        @T("Admin.Common.Save")
                    </button>
                </div>
            </div>
            <div class="form-group row">
                <div class="col-md-3">
                </div>
                <div class="col-md-9">
                    @Model.PermissionName
                </div>
            </div>
            <div class="form-group row">
                <div class="col-md-3">
                    <nop-label asp-for="SelectedCustomerRoleIds" />
                </div>
                <div class="col-md-9">
                    <nop-select asp-for="SelectedCustomerRoleIds" asp-items="Model.AvailableCustomerRoles" asp-multiple="true" />
                    <script>
                        $(function () {
                            var rolesIdsInput = $('#@Html.IdFor(model => model.SelectedCustomerRoleIds)').select2({
                                closeOnSelect: false,
                                @if (!Model.AvailableCustomerRoles.Any())
                                {
                                    <text>
                                        disabled: true,
                                        placeholder: '@T("Admin.Configuration.ACL.NoCustomerRolesAvailable")',
                                    </text>
                                }
                            });
                        });
                    </script>
                </div>
            </div>
        </div>
    </section>
</form>